package com.ruoyi.system.service.impl;

import java.util.List;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.system.constants.BookStatusConst;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.LibBookMapper;
import com.ruoyi.system.domain.LibBook;
import com.ruoyi.system.service.ILibBookService;
import com.ruoyi.common.core.text.Convert;

/**
 * 图书馆Service业务层处理
 *
 * @author ruoyi
 * @date 2024-05-09
 */
@Service
public class LibBookServiceImpl implements ILibBookService {
    @Autowired
    private LibBookMapper libBookMapper;

    /**
     * 查询图书馆
     *
     * @param id 图书馆主键
     * @return 图书馆
     */
    @Override
    public LibBook selectLibBookById(Long id) {
        return libBookMapper.selectLibBookById(id);
    }

    /**
     * 查询图书馆列表
     *
     * @param libBook 图书馆
     * @return 图书馆
     */
    @Override
    public List<LibBook> selectLibBookList(LibBook libBook) {
        return libBookMapper.selectLibBookList(libBook);
    }

    /**
     * 新增图书馆
     *
     * @param libBook 图书馆
     * @return 结果
     */
    @Override
    public int insertLibBook(LibBook libBook) {
        libBook.setStatus(BookStatusConst.NORMAL);
        libBook.setUpdateBy(ShiroUtils.getLoginName());
        libBook.setUpdateTime(DateUtils.getNowDate());
        libBook.setCreateBy(ShiroUtils.getLoginName());
        libBook.setCreateTime(DateUtils.getNowDate());
        return libBookMapper.insertLibBook(libBook);
    }

    /**
     * 修改图书馆
     *
     * @param libBook 图书馆
     * @return 结果
     */
    @Override
    public int updateLibBook(LibBook libBook) {
        libBook.setUpdateBy(ShiroUtils.getLoginName());
        libBook.setUpdateTime(DateUtils.getNowDate());
        return libBookMapper.updateLibBook(libBook);
    }

    /**
     * 批量删除图书馆
     *
     * @param ids 需要删除的图书馆主键
     * @return 结果
     */
    @Override
    public int deleteLibBookByIds(String ids) {
        return libBookMapper.deleteLibBookByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除图书馆信息
     *
     * @param id 图书馆主键
     * @return 结果
     */
    @Override
    public int deleteLibBookById(Long id) {
        return libBookMapper.deleteLibBookById(id);
    }
}
